using System;
using Android.Locations;
using Android.OS;
using Android.Util;
using Android.Widget;

namespace MapDrawer
{
    class MyLocationListener : Java.Lang.Object, ILocationListener
    {
        private readonly PathTracker _base;

        public MyLocationListener(PathTracker @base)
        {
            _base = @base;
        }

        public void OnLocationChanged(Location location)
        {
            Log.Debug("Location provider", "Location has been updated: " + location.Longitude + ", " + location.Latitude);
            var pt = new Point(location);
            _base.Locations.Add(pt);
            _base.FindViewById<TextView>(Resource.Id.progressLog).Text = "Votre vitesse: " + Math.Floor(location.Speed * 3.6) + "km/h";
        }

        public void OnProviderDisabled(string provider)
        {
            Log.Debug("Location provider", provider + "is now disbabled");
        }

        public void OnProviderEnabled(string provider)
        {
            Log.Debug("Location provider", provider + "is now enabled");
        }

        public void OnStatusChanged(string provider, Availability status, Bundle extras)
        {
            Log.Warn("Gps status changed", provider + " is " + status);
        }
    }
}